<template>
    <BasePanel width="100%" height="218px" :show-header="false">
        <template #default>
            <div class="panel-content">
                <!-- 中央环保督察 -->
                <div class="card-type-1">
                    <div class="big-title">{{ card1Data.title }}</div>
                    <div class="card-type-1-content">
                        <div
                            class="type-item-1"
                            v-for="item in card1Data.listData"
                            :key="item.label"
                        >
                            <div class="info-box">
                                <span class="label">{{ item.label }}</span>
                                <div class="value-box">
                                    <span class="v1">{{ item.done }}</span>
                                    <span class="v2">/</span>
                                    <span class="v3">{{ item.total }}</span>
                                </div>
                            </div>
                            <PercentBar :height="12" :list="transformPercentBarData(item)" />
                        </div>
                    </div>
                </div>
                <!-- 省委专项督查 -->
                <div class="card-type-1">
                    <div class="big-title">{{ card2Data.title }}</div>
                    <div class="card-type-1-content">
                        <div
                            class="type-item-1"
                            v-for="item in card2Data.listData"
                            :key="item.label"
                        >
                            <div class="info-box">
                                <span class="label">{{ item.label }}</span>
                                <div class="value-box">
                                    <span class="v1">{{ item.done }}</span>
                                    <span class="v2">/</span>
                                    <span class="v3">{{ item.total }}</span>
                                </div>
                            </div>
                            <PercentBar :height="12" :list="transformPercentBarData(item)" />
                        </div>
                    </div>
                </div>
                <!-- 主动问题曝光 -->
                <div class="card-type-2">
                    <div class="big-title">{{ card3Data.title }}</div>
                    <img class="icon" :src="card3Data.icon" alt="" />
                    <div class="year">{{ card3Data.year }}</div>
                    <div class="value-box">
                        <span class="value">{{ card3Data.value }}</span>
                        <span class="unit">{{ card3Data.unit }}</span>
                    </div>
                </div>
                <!-- 环境执法 -->
                <div class="card-type-3">
                    <div class="big-title">{{ card4Data.title }}</div>
                    <img class="icon" :src="card4Data.icon" alt="" />
                    <div class="info-box">
                        <span class="label">案件</span>
                        <div class="value-box">
                            <span class="value">{{ card4Data.v1 }}</span>
                            <span class="unit">件</span>
                        </div>
                    </div>
                    <div class="info-box">
                        <span class="label">处罚</span>
                        <div class="value-box">
                            <span class="value">{{ card4Data.v2 }}</span>
                            <span class="unit">万元</span>
                        </div>
                    </div>
                </div>
            </div>
        </template>
    </BasePanel>
</template>

<script setup lang="ts">
import BasePanel from '@/components/BasePanel/index.vue'
import PercentBar from '@/components/PercentBar/index.vue'
// import { useGlobalStore } from '@/store/global'
import { getFpiAssetsFile } from '@/utils/tools'

// 全局数据
// const globalStore = useGlobalStore()

// 图片
const icon1 = getFpiAssetsFile('global/card-icon-1.png')
const icon2 = getFpiAssetsFile('global/card-icon-2.png')

// 中央环保督查
const card1Data = reactive({
    title: '中央环保督察(第二轮)',
    listData: [
        {
            label: '反馈问题',
            total: 14,
            done: 14,
        },
        {
            label: '信访问题',
            total: 1157,
            done: 1100,
        },
    ],
})

// 省委专项督查
const card2Data = reactive({
    title: '省委专项督查(2022年)',
    listData: [
        {
            label: '反馈问题',
            total: 47,
            done: 49,
        },
        {
            label: '信访问题',
            total: 180,
            done: 357,
        },
    ],
})

// 转化数据
const transformPercentBarData = (info: any) => {
    return [
        {
            name: '完成',
            value: info.done,
            color: 'rgba(45, 255, 132, 1)',
        },
        {
            name: '未完成',
            value: info.total - info.done,
            color: 'rgba(255, 15, 0, 1)',
        },
    ]
}

// 主动问题曝光
const card3Data = reactive({
    title: '主动问题曝光',
    icon: icon2,
    year: '2024年',
    value: 311,
    unit: '个',
})

// 环境执法
const card4Data = reactive({
    title: '环境执法(2024年)',
    icon: icon1,
    v1: 997,
    v2: '9588.91',
})
</script>

<style lang="scss" scoped>
.panel-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;

    .big-title {
        width: 100%;
        font-size: 20px;
        font-weight: 700;
        line-height: 20px;
        color: rgba(255, 255, 255, 1);
        height: 20px;
        white-space: nowrap;
    }

    .card-type-1 {
        width: 220px;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;

        .card-type-1-content {
            width: 100%;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: center;
            height: calc(100% - 52px);
            gap: 20px;

            .type-item-1 {
                width: 100%;

                .info-box {
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    margin-bottom: 12px;

                    .label {
                        font-size: 18px;
                        font-weight: 700;
                        line-height: 18px;
                        height: 18px;
                        color: rgba(255, 255, 255, 1);
                    }

                    .value-box {
                        display: flex;
                        gap: 2px;
                        align-items: center;
                        justify-content: flex-end;
                        font-family: Oswald;

                        .v1,
                        .v2,
                        .v3 {
                            font-size: 24px;
                            font-weight: 400;
                            line-height: 24px;
                            height: 24px;
                        }

                        .v1 {
                            color: rgba(1, 254, 133, 1);
                        }

                        .v2 {
                            color: rgba(255, 255, 255, 0.6);
                        }

                        .v3 {
                            color: #fff;
                        }
                    }
                }
            }
        }
    }

    .card-type-2 {
        display: flex;
        flex-direction: column;
        height: 100%;
        justify-content: space-between;
        align-items: center;

        .icon {
            width: 56px;
            height: 56px;
        }

        .year {
            font-size: 18px;
            font-weight: 700;
            line-height: 18px;
            color: rgba(255, 255, 255, 0.8);
            height: 18px;
        }

        .value-box {
            display: flex;
            align-items: flex-end;
            gap: 4px;

            .value {
                font-size: 28px;
                font-weight: 400;
                line-height: 28px;
                color: rgba(1, 254, 133, 1);
                height: 28px;
                font-family: Oswald;
            }
            .unit {
                font-size: 16px;
                font-weight: 700;
                line-height: 16px;
                color: rgba(255, 255, 255, 0.6);
                height: 16px;
            }
        }
    }

    .card-type-3 {
        height: 100%;
        width: 162px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: flex-start;
        position: relative;

        .icon {
            width: 56px;
            height: 52px;
            user-select: none;
            position: absolute;
            right: 0;
            top: 42px;
        }

        .info-box {
            display: flex;
            flex-direction: column;
            gap: 12px;

            .label {
                font-size: 18px;
                font-weight: 700;
                line-height: 18px;
                color: rgba(255, 255, 255, 1);
                height: 18px;
            }

            .value-box {
                display: flex;
                align-items: flex-end;
                gap: 4px;

                .value {
                    font-size: 28px;
                    font-weight: 400;
                    line-height: 28px;
                    color: rgba(1, 254, 133, 1);
                    height: 28px;
                    font-family: Oswald;
                }
                .unit {
                    font-size: 16px;
                    font-weight: 700;
                    line-height: 16px;
                    color: rgba(255, 255, 255, 0.6);
                    height: 16px;
                }
            }
        }
    }
}
</style>
